package com.zut.utils;

import com.zut.dao.EmployeeDao;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author 张晨
 * @date 2024/9/20 19:45
 * @desc
 */
public class MybatisUtil {
    public static SqlSession getSqlSession(){
        {
            InputStream in;
            try {
                in = Resources.getResourceAsStream("mybatis-config.xml");
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            SqlSession sqlSession =new SqlSessionFactoryBuilder().build(in).openSession(true);
            return sqlSession;
        }
    }
}
